<?php include PATH_TPL."/admin/tpl.header.phtml"?>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row bt">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                        <i class="fa  fa-fw fa-reorder"></i>提醒管理
                        </li>
                    </ol>
                </div>
            </div>
            <div class="cent">
    <span class="bg" style="position: absolute;width: 100%;height: 100%;background: black;
    opacity: 0.3;z-index: 10;padding: 0;display: none"></span>
            <div class="modal fade" id="modal_box" tabindex="-1" role="dialog" aria-labelledby="modal_delLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content" style="width:750px;">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="myModalLabel">新增提醒</h4>
                            </div>
                            <div class="modal-body" style="width:750px;">
                                <form method="post">
                                <span>部门：</span>
                                <select name="department">
                                    <option value="0">请选择</option>
                                    <?php foreach($tDDatas as $tDRow){?>
                                    <option value="<?=$tDRow['num']?>"><?=$tDRow['introduce']?></option>
                                    <?php }?>
                                </select>
                                <span class="senior_name">老人姓名：</span>
                                <select name="senior">
                                <option>请选择</option>
                                </select>
                                <span>提醒类型：</span>
                                <select name="remind_type">
                                    <option value="0">请选择</option>
                                    <option value="1">铃声</option>
                                    <option value="2">震动</option>
                                </select>
                                <span>事件类型：</span>
                                <select name="news_type">
                                    <option value="0">请选择</option>
                                    <?foreach($tEDatas as $tERow){?>
                                    <option value="<?=$tERow['num']?>"><?=$tERow['introduce']?></option>
                                    <?}?>
                                </select></br>
                                <div class="space" style="margin-top:10px;"></div>
                                <span>提醒时间段：</span>
                                <input type="text" name="startdate" id="datetime" onclick="WdatePicker();"/>
                                <span>——</span>
                                <input type="text" name="enddate" id="datetime" onclick="WdatePicker();"/></br>
                                <div class="space" style="margin-top:10px;"></div>
                                <span>提醒时间点：</span>
                                <input type="text" name="respond_time" value="" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"/></br>
                                <div class="space" style="margin-top:10px;"></div>
                                <span>提醒内容：</span></br>
                                <div class="space" style="margin-top:10px;"></div>
                                <textarea name="description" value="" style="margin-left:54px;width:450px;"></textarea></br>
                                <div class="space" style="margin-top:10px;"></div>
                                <span>备注：</span></br>
                                <div class="space" style="margin-top:10px;"></div>
                                <textarea name="remarks" value="" style="margin-left:54px;width:450px;"></textarea></br>
                            </div>
                            <div class="modal-footer">
                                <button class="btn btn-danger btn-sm ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false" onclick="addUser()">
                                    <span class="ui-button-text">
                                        <i class="icon-ok bigger-110"></i>
                                        确 定
                                    </span>
                                </button>
                                <button class="btn btn-sm ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false" data-dismiss="modal">
                                    <span class="ui-button-text">
                                        <i class="icon-remove bigger-110"></i>
                                        取 消
                                    </span>
                                </button>
                            </div>
                            </form>
                        </div>
                    </div>
                </div>
            <div class="column">
                <div class="text-center"><h4>事件列表</h4></div>
                <form method="get" action="/admin_remind" class="form">
                <span style="margin-left:40px;">老人姓名：</span><input type="text" style="width:80px;height:30px;" name="name" value="<?=$PName?>"/>
                <span style="margin-left:20px;">委托人联系电话：</span><input type="text" style="width:100px;height:30px;" name="phone" />
                <span>入院时间：</span>
                <span style="cursor:pointer;" onclick="WdatePicker({el:'datetime'})" class="dateicon"><span class="glyphicon glyphicon-calendar"></span></span>
                <input type="text" name="date" id="datetime" onclick="WdatePicker();"/>
                <span style="margin-left:20px;">所在部门：</span>
                <select name="department">
                    <option value="0">不限</option>
                    <?foreach($tDDatas as $tDRow){?>
                    <option value="<?=$tDRow['num']?>" <?if($pDepartment == $tDRow['num']){echo 'selected';}?>><?=$tDRow['introduce']?></option>
                    <?}?>
                </select>
                <button type="button" class="btn btn-blue" id="search">查询</button>
                <a class="btn btn-blue" onclick="$('#modal_box').modal('toggle');">新增提醒</a>
                </form>
            </div>
            <div class="panel-body text-center">
                <table class="table table-hover" id="table_list">
                    <thead>
                        <tr>
                            <td>编号</td>
                            <td>老人姓名</td>
                            <td>所在部门</td>
                            <td>性别</td>
                            <td>提醒内容</td>
                            <td>提醒时间段</td>
                            <td>提醒时间点</td>
                            <td>备注</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                    <?foreach($tDatas as $tRow){?>
                    <tr>
                        <td><?=$tRow['id']?></td>
                        <td><?=empty($tRow['name'])?'未知姓名':$tRow['name']?></td>
                        
                        <td><?=$tRow['department_introduce']?></td>
                        <td><?=$getSex[$tRow['sex']]?></td>
                        <td><?=$tRow['description']?></td>
                        <td><?=date('Y-m-d',$tRow['startdate'])?>~<?=date('Y-m-d',$tRow['enddate'])?></td>
                        <td><?=$tRow['respond_time']?></td>
                        <td><?=$tRow['remarks']?></td>
                        <td>
<a role="menuitem" class="btn btn-blue btn-xs tooltips demo_4" tabindex="-1" href="/admin_user/userinfo?id=<?=$tRow['id']?>" data-original-title="详情" data-placement="top" ><i class="fa fa-edit"></i></a>
<a role="menuitem" class="btn btn-orange btn-xs tooltips demo_4" tabindex="-1" href="#" data-original-title="删除" data-placement="top" onclick="cg_confirm_del('/admin_remind/delete?id=<?=$tRow['id']?>','/admin_remind')"><i class="fa fa-times"></i></a>
</td>
                    </tr>
                    <?}?>
                </table>
                <?=$tShow?>
            </div>
        </div>
        <div class="subviews">
            <div class="subviews-container"></div>
        </div>
    </div>
    <!-- end: PAGE -->
</div>
<!-- end: MAIN CONTAINER -->
<script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
<script>
$('#search').click(function(){
    $('.form').submit();
});
/*获取地址栏参数*/
function GetQuery(key){
	var search = location.search.slice(1);//得到get方式提交的查询字符串
	var arr = search.split("&");
	for(var i = 0; i < arr.length; i++){
		var ar = arr[i].split("=");
		if(ar[0] == key){
			return ar[1];
		}
	}
}
$('select[name="department"]').change(function(){
    var department_id = $(this).val();
    $.post('/admin_remind',{department_id:department_id},function(obj){
        $('select[name="senior"]').remove();
        if(obj.status == 1){
            var data = obj.data;
            var html = (
                '<select name="senior">'
            );
            $.each(data,function(key,row){
                html += '<option value="'+row.id+'">'+row.name+'</option>';
            }); 
            html += '</select>';
            $('.senior_name').append(html);
        }
    });
});
function addUser(){
    var data = $('form').serialize();
    $.post('/admin_remind/add',data,function(obj){alert(obj.msg);location.href="/admin_remind";});
}
    var color="#eeeeee";
    $("#table_list tr:odd td").css("background-color",color);  //改变偶数行背景色
    /* 把背景色保存到属性中 */
    $("#table_list tr:odd").attr("bg",color);
</script>
<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
